﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Controller;
using Models;
using System.Collections.Generic;
namespace TestUserController
{
    [TestClass]
    public class TestUserController
    {
        [TestMethod]
        public void TestGetAllUser()
        {
            UserController user = new UserController();
            
            List<TblUser> list = new List<TblUser>();
            list = user.GetAllData();
            if (list!=null)
            {
                Console.Write("co du lieu");
            }

        }

        [TestMethod]
        public void InsertUser()
        {
            for (int i = 0; i < 10; i++)
            {
                UserController user = new UserController();
                TblUser u = new TblUser();
                u.Email = "administration@gmail.com";
                u.Address = "30 a trần bình trọng";
                u.Fullname = "user number " + i.ToString();
                u.IsConfirm = true;
                u.Password = "123@123";
                u.Phone = "0123456789";
                u.Positions = 1;
                u.Username = "username"+i.ToString();

                user.objUser = u;

                if (user.AddData())
                {
                    Console.Write("inser du lieu thanh cong cho {0}", u.Username);
                }
                else
                {
                    Console.Write("Khong the insert du lieu");
                }
            }
            

        }

        [TestMethod]
        public void GetUserByKey()
        { 
            UserController c = new UserController();
            List<TblUser> list = c.GetAllDataByPositions(1);
            foreach (TblUser item in list)
            {
                Console.WriteLine("{0}, {1}", item.Positions, item.Username);
            }
        }

         [TestMethod]
        public void DeleteUser()
        {
            UserController user = new UserController();
            if (user.DeleteData(2))
            {
                Console.Write("đã xóa user");
            }
            else
            {
                Console.Write("Không thể xóa user");
            }
        }

         [TestMethod]
         public void UpdateUser()
         {
             UserController ctr = new UserController();
             ctr.objUser.ID = 7;
             ctr.objUser.Username = "name";

             ctr.UpdateData();
         }
    }
}
